﻿using Autofac.Core;
using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Dto.Output.EarTagOutput;
using IntelligentAgriculture.Contracts.Interface.EarTagService;
using IntelligentAgriculture.WebAPI.Application.Command.EarTageCommand;
using IntelligentAgriculture.WebAPI.Application.Command.StartCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.EarTageManageCommandJamdler
{
    public class EarTageFindCommandHandler : IRequestHandler<EarTageFindCommand, Results<EarTageShowsOutPut>>
    {
        private readonly IEarTageService _iearTageService;

        public EarTageFindCommandHandler(IEarTageService _iearTageServices)
        {
            _iearTageService = _iearTageServices;
        }
        /// <summary>
        /// 处理EarTageFindCommand命令的方法
        /// </summary>
        /// <param name="request">请求对象，包含id参数</param>
        /// <param name="cancellationToken">取消操作的取消令牌</param>
        /// <returns>异步返回包含EarTageShowsOutPut结果的任务</returns>
        public async Task<Results<EarTageShowsOutPut>> Handle(EarTageFindCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = await _iearTageService.Find(request.id);
                return Results<EarTageShowsOutPut>.DataResult(list);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
